package com.atguigu.gmall.mq.receiver;

import com.atguigu.gmall.mq.config.DelayedMqConfig;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author mqx
 * @date 2020-8-13 10:25:48
 */
@Component
@Configuration
public class DelayReceiver {
    // 消息监听
    @RabbitListener(queues = DelayedMqConfig.queue_delay_1)
    public void getDealyMsg(String msg){
        System.out.println("接收到的消息：\t"+msg);
        // 发送消息 在队列中设置了一个过期时间 10秒钟 ，
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        System.out.println(sf.format(new Date())+ "接收到消息了。。。。"+msg);

    }
}
